package cn.kgm.factory;

import cn.kgm.factory.shape.Shape;

import java.util.Optional;

/**
 * 工厂模式
 */
public class FactoryPatternDemo {
    public static void main(String[] args) {
        Shape shape = ShapeFactory.shapeBuilderByEnum("SQUARE");
        Optional.ofNullable(shape).orElseThrow(() -> new RuntimeException("运行错误，不存在该类型！"));
        shape.draw();
    }
}
